<div class="col-sm-10 col-md-9 col-lg-7">
    <form class="form-horizontal" role="form" action="{:U('Category/update')}" method="POST">
        <div class="form-group">
            <label for="pid">上级分类</label>
            <select class="form-control" id="pid" name="pid">
                <option value="0">/</option>
                <volist name="categorys" id="category" key="key">
                    <option value="{$category['id']}" <eq name="info.pid" value="$category['id']">selected=selected</eq> >
                    <for start="1" end="$category['depth']">
                        <if condition="($i+1) eq $category['depth']">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <else/>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </if>
                    </for>
                    {$category.title}</option>
                </volist>
            </select>
        </div>
        <div class="form-group">
            <label for="title">分类标题 <span class="help">(不能为空)</span></label>
            <input type="text" class="form-control" id="title" name="title" value="<if condition="isset($info['title'])">{$info.title}</if>">
        </div>
        <div class="form-group">
            <label for="name">分类标识 <span class="help">(可以为空)</span></label>
            <input type="text" class="form-control" id="name" name="name" value="<if condition="isset($info['name'])">{$info.name}</if>">
        </div>
        <style>
            #cover_id{
                color: #fff;
                background: #337ab7;
                margin: 10px;
            }
                #cover_id-button{
                    text-align: center;
                }
        </style>
        <div class="form-group">
            <label for="name">图标 <span class="help">(可以为空)</span></label><br>
            <input id="cover_id" type="file" style="display:none;" accept="image/gif, image/jpeg, image/png" >
            <img class="cover_id" src="{:get_cover($info['cover_id'],'path')}" onerror="this.src='__IMG__/class-logo.png'" width="40" height="40">
            <input type="text" class="cover_id" style="display: none;" name="cover_id" value="<if condition="isset($info['cover_id'])">{$info.cover_id}</if>">
        </div>
        <div class="hidden">
            <input name="id" value="<if condition="isset($info['id'])">{$info.id}</if>">
        </div>

        <button type="submit" class="btn btn-default">提交</button>
    </form>
    <script>
        function trace(data){
            console.log(data);
        }
        $(function(){
//            imgUpload("cover_id");
//            function imgUpload(className){
//                var input = $("input."+className);
//                $(input).prop("hidden",true);
//                trace(input);
//                var cover_id = $(input).val();
//                trace(cover_id);
//
//
//
//            }
            $("#cover_id").uploadify({
                'swf'      : '/static/plugin/uploadify/uploadify.swf',
                'uploader' : '{:U("Picture/upload")}',
                "buttonText"      : "上传图片",
                'fileTypeExts'    : '*.jpg; *.png; *.gif;',
                "onUploadSuccess" :uploadPicture
                // Put your options here
            });
            function uploadPicture(file,data){
                var data = $.parseJSON(data);
                trace(data);
                trace(data.status);
                trace(data.id);
                if(1 == data.status){
                    trace('上传成功');
                    $("img.cover_id").attr('src',data.path);
                    $("input[name='cover_id']").val(data.id);
                }
                trace($("input[name='cover_id']").val());
            }
        });
    </script>
</div>